<?php

namespace App\Models\Kms\App;

use App\Models\BaseModel;
use App\Models\Kms\Fs\FsDepartmentsModel;
use App\Models\Kms\User\KmsUser;
use App\Models\Traits\KfSoftDeletes;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ClientsAuthModel extends BaseModel
{
    use KfSoftDeletes;

    protected $table = "kms_clients_auth";

    const TYPE_FS_USER       = 1;
    const TYPE_FS_DEPARTMENT = 2;

    const TYPE_TEXT = [
        self::TYPE_FS_USER       => "飞书用户",
        self::TYPE_FS_DEPARTMENT => "飞书部门"
    ];

    /**
     * @return HasOne
     */
    public function fsUserRel(): HasOne
    {
        return $this->hasOne(KmsUser::class, "userId", "targetId");
    }

    /**
     * @return HasOne
     */
    public function fsDepartmentRel(): HasOne
    {
        return $this->hasOne(FsDepartmentsModel::class, "openDepartmentId", "targetId");
    }
}
